<template>
  <div>
    <van-row>
      <van-col span="6"><lef></lef></van-col>
      <van-col span="18">
        <van-row>
          <van-col span="24"><headers></headers></van-col>
        </van-row>
        <van-row>
          <p v-for="(k,v) in tlist" :key="k.id">

           <span v-if="v=='亲家凭证'">{{v}}:<img :src="k" alt="" height="250" width="150"></span>
           <span v-else>{{v}}:{{k}}</span>


          </p>


         <table>
           <caption>审批信息</caption>
           <tr v-for="j in records" :key="j.id">
             <td>{{j.username}}</td>
             <td>{{j.is_agree}}</td>
             <td>{{j.add_time}}</td>
             <td>{{j.reason}}</td>
           </tr>
         </table>
          <br>
          <br>
          <br>

          <van-field label="是否同意">
            <template #input>
              <van-radio-group v-model="agree" direction="horizontal">
                <van-radio name="1">同意</van-radio>
                <van-radio name="0">不同意</van-radio>
              </van-radio-group>
            </template>
          </van-field>
          <br>
          <br>
          <van-field label="审批意见" v-model="reason"/>
          <van-button @click="add_yijian">提交</van-button>
        </van-row>


      </van-col>
    </van-row>


  </div>
</template>

<script>
import myaxios from "@/http/axios";
import Lef from "@/components/veiw/lef";
import Headers from "@/components/veiw/headers";

export default {
  name: "my_task_handle",
  components: {Headers, Lef},
  data() {
    return {
      data1: '',
      taskhandle:[],
      tlist:[],
      id:this.$route.query.id,
      agree:0,
      reason:'',
      records:[],
      userid:localStorage.getItem('userid'),
      name:localStorage.getItem('username')
    }
  },
  methods: {
    task_handle() {
      myaxios('mytaskhandle?id=' + this.id, 'get').then(res => {
        this.taskhandle = res.list[0]
        this.tlist = JSON.parse(res.list.params)
        this.records = res.records
      })
    },
    add_yijian() {
      myaxios('taskrecordM', 'post', {
        'taskid': this.id,
        'userid': 2,
        'name': this.name,
        'agree': this.agree,
        'reason': this.reason
      }).then(res => {
          alert(res)
      })
    }
  },
  mounted() {
    this.task_handle()
  }
}
</script>

<style scoped>

</style>